From ca1134470471220714c16e78149cdd10dab31966 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Tue, 20 Mar 2007 11:44:13 +0000 Subject: [PATCH] When creating a VBD, save the devid in the device info structure. If creation fails, remove the device config entry. Signed-off-by: Tom Wilkie --- tools/python/xen/xend/XendDomainInfo.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 99c3ddd425..a1d3c16f88 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -2301,12 +2301,21 @@ class XendDomainInfo: dev_control = None if vdi_image_path.startswith('tap'): - dev_control = self.getDeviceController('tap') + dev_control = self.getDeviceController('tap') else: dev_control = self.getDeviceController('vbd') - - config['devid'] = dev_control.createDevice(config) + try: + devid = dev_control.createDevice(config) + dev_control.waitForDevice(devid) + self.info.device_update(dev_uuid, + cfg_xenapi = {'devid': devid}) + except Exception, exn: + log.exception(exn) + del self.info['devices'][dev_uuid] + self.info['vbd_refs'].remove(dev_uuid) + raise + return dev_uuid def create_phantom_vbd_with_vdi(self, xenapi_vbd, vdi_image_path): -- 2.30.2